// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#pragma once

#include <utility>

#include <pollux/core/plan_node.h>
#include <pollux/exec/split.h>
#include <pollux/tool/trace/operator_replayer_base.h>

namespace kumo::pollux::tool::trace {

/// The replayer to replay the traced 'TableScan' operators.
class TableScanReplayer final : public OperatorReplayerBase {
 public:
  TableScanReplayer(
      const std::string& traceDir,
      const std::string& queryId,
      const std::string& taskId,
      const std::string& nodeId,
      const std::string& operatorType,
      const std::string& driverIds,
      uint64_t queryCapacity,
      melon::Executor* executor)
      : OperatorReplayerBase(
            traceDir,
            queryId,
            taskId,
            nodeId,
            operatorType,
            driverIds,
            queryCapacity,
            executor) {}

  RowVectorPtr run(bool copyResults = true) override;

 private:
  core::PlanNodePtr createPlanNode(
      const core::PlanNode* node,
      const core::PlanNodeId& nodeId,
      const core::PlanNodePtr& /*source*/) const override;

  std::vector<exec::Split> getSplits() const;
};

} // namespace kumo::pollux::tool::trace
